﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace SqlReplace
{
    public static class RegHelper
    {
        static int lineRowNum = 0;
        static bool IsChanged = false;
        public static List<string> matchContent = new List<string>();
        public static StringBuilder fileContent = new StringBuilder();
        public static StringBuilder otherParam = new StringBuilder();
        static bool IsContinue = false;
        static bool IsEndLine = false;
        static List<string> addParmStr = new List<string>();
        static bool NeedAddParmStr = false;

        public static string MatchMaybe(string linedata)
        {
            Regex reg = new Regex(@"\{\s*?\d\s*?\}");
            if (!IsChanged && 
                (reg.IsMatch(linedata)
                ||linedata.Contains("MakeH")
                ||linedata.Contains("GetOrgSql_fctCode_lineCode("))
                )
            {
                return($"{lineRowNum}  {linedata}");
            }
            return null;

        }
        public static void Init()
        {
            matchContent = new List<string>();
            fileContent.Clear();
            otherParam.Clear();
            IsContinue = false;
            lineRowNum = 0;
        }

        public static void CheckData(string lineData)
        {
            lineRowNum++;
            var maybematch = MatchMaybe(lineData);

            if (!string.IsNullOrWhiteSpace(maybematch))
            {
                otherParam.AppendLine(maybematch);

            }
        }

        public static void DealData(string lineData, List<string> methodList)
        {
            lineRowNum++;
            IsEndLine = lineData.EndsWith(";");
            IsChanged = false;
            IsContinue = false;
            NeedAddParmStr = false;
            addParmStr.Clear();
            if (lineData.Contains("public"))
            {

                AddMethodListToClassList(methodList);
                methodList.Clear();
                methodList.Add(lineData);
                methodList.Add("List<OracleParameter> ListParams = new List<OracleParameter>();");
            }
            lineData = MatchPlusAddToList(lineData, methodList);
            lineData = MatchMuitInPlusAddToList(lineData, methodList);
            lineData = MatchMuitInOneLineAddToList(lineData, methodList);
            lineData = MatchTwoFormatAddToList(lineData, methodList);
            lineData = MatchInOneLineAddToList(lineData, methodList);
            lineData= MatchSUMMWORK_YMDBETWEENAddToList(lineData, methodList);
            lineData= MatchOneTwoFormatAddToList(lineData, methodList);
            lineData= MatchInAddToList(lineData, methodList);
            lineData= MatchSUBSTRAddToList(lineData, methodList);
            lineData = MatchWORK_YMDAddToList(lineData, methodList);
            lineData= MatchGetOrgSql_fctCode_lineCodeAddToList(lineData, methodList);
            lineData= MatchIDC_DTL_CODEAddToList(lineData, methodList);
            var maybematch = MatchMaybe(lineData);

            if (!string.IsNullOrWhiteSpace(maybematch))
            {
                otherParam.AppendLine(maybematch);

            }
            fileContent.AppendLine(lineData);
            if (NeedAddParmStr)
            {
                foreach (var item in addParmStr)
                {
                    fileContent.AppendLine(item);
                    lineRowNum++;
                }
              
            }
        }
        public static void AddMethodListToClassList(List<string> methodList)
        {
            if (methodList.Count > 2)
            {
                matchContent.Add("");
                matchContent.AddRange(methodList);
            }
        }

        public static string MatchSUMMWORK_YMDBETWEENAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            //AND\s*?SUMM.WORK_YMD\s*?BETWEEN
            //  A.BASE_YMD BETWEEN (
            //  sb.AppendFormat(@"  AND BASE_YMD BETWEEN (SELECT WEEKNO_START_YMD FROM TBC_MD_WEEKNO WHERE BASE_YY = SUBSTR('{0}', 0,4) AND LPAD(BASE_WEEKNO, 2, 0) = SUBSTR('{0}', 5 ,2 ))  
            // sb.AppendFormat(@" AND SUMM.WORK_YMD BETWEEN (SELECT WEEKNO_START_YMD FROM TBC_MD_WEEKNO WHERE BASE_YY = SUBSTR('{0}', 0,4) AND LPAD(BASE_WEEKNO, 2, 0) = SUBSTR('{0}', 5 ,2 ))   
            Regex reg = new Regex(@"(SUMM.WORK_YMD|A.BASE_YMD|A.APLY_YMD|BASE_YMD)\s*?BETWEEN");
            if (reg.IsMatch(linedata))
            {
                linedata=linedata.Replace("'{0}'", ":FILTER_START");
            }
            return linedata;

        }

        public static string MatchOneTwoFormatAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            var IsRepalce = linedata.Contains("Replace");

            var regstr = @"[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?""\s*?,\s*?(\S+?)\s*?\,\s*?(\S+?)\s*?\)\s*?\;";
            if (IsRepalce)
            {
                regstr = @"[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?""\s*?,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\)\s*?\;";
            }
            Regex reg = new Regex(regstr);
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 2)
                {
                    var replactStr = IsRepalce ? @"(?<=[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?""\s*?),\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?(?=\)\s*?\;)"
                        : @"(?<=[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?""\s*?),\s*?(\S+)\s*?\,\s*?(\S+)\s*?(?=\)\s*?\;)";
                    linedata = Regex.Replace(linedata, replactStr, "");
                    {
                        var parName1 = match.Groups[1].Value;
                        var pars = parName1.Split('.');
                        var oraParName1 = IsRepalce ? pars[pars.Length - 2].ToUpper() : pars.Last().ToUpper();
                        var parString = $@"ListParams.Add(new OracleParameter(""{oraParName1}"",{parName1} ));";
                        AddParStringToMethodList(parString, methodList);
                   
                    }
                    {
                        var parName2 = match.Groups[2].Value;
                        var pars = parName2.Split('.');
                        var oraParName2 = IsRepalce ? pars[pars.Length - 2].ToUpper() : pars.Last().ToUpper();
                        var parString2 = $@"ListParams.Add(new OracleParameter(""{oraParName2}"",{parName2} ));";
                        AddParStringToMethodList(parString2, methodList);
                        //'{1}'
                        linedata = Regex.Replace(linedata, @"\'\s*?\{\s*?1\s*?\}\s*?\'", $":{oraParName2}");
                    }


                }
            }
            return linedata;
        }
        public static string MatchPlusAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            //WHERE A.WORK_YMD  BETWEEN  '" + instance.DateSTART + @"' AND '" + instance.DateEND + @"' --******时间
            Regex reg = new Regex(@"'\s*?""\s*?\+\s*?(\S+)\s*?\+\s*?@\s*?""\s*?'");
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 1)
                {

                    var parName = match.Groups[1].Value;
                    var oraParName = parName.Split('.').Last().ToUpper();
                    var parString = $@"ListParams.Add(new OracleParameter(""{oraParName}"",{parName} ));";
                    AddParStringToMethodList(parString, methodList);
                    //'"+DateSt+@"'
                    linedata = Regex.Replace(linedata, @"('\s*?""\s*?\+\s*?)" + parName + @"(\s*?\+\s*?@\s*?""\s*?')", $":{oraParName}");
                }
            }
            return linedata;

        }

        public static string MatchMuitInPlusAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            //   //  AND     (A.FCT_CODE, T6.MFG_PART_CODE) IN ( {0} )  ) ", MFG_PART_CODE);
            //  sqlString += " AND (A.FCT_CODE, A.LINE_CODE) IN (" + LINE_CODE + ") ";
            Regex reg = new Regex(@"AND\s*?\(\s*?\S*?FCT_CODE[\s\S]*?IN\s*?\(\s*?""\s*?\+\s*?(\S+)\s*?\+\s*?""\s*?\)");
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 1)
                {

                    var parName = match.Groups[1].Value;
                    var oraParName = parName.Split('.').Last().ToLower();
                    //var parString = $@"string {oraParName} =  DbHelperOra.GetParameterKeysAndValues(""FCT_CODE,{oraParName.ToUpper()}"", {parName}, ListParams);";
                    var parString = $@"string {oraParName} = DbHelperOra.GetParameterKeysAndValues(""FCT_CODE,{oraParName.ToUpper()}"", {parName}, ListParams);";
                    AddParStringToMethodList(parString, methodList);
                    // sqlString += " AND (A.FCT_CODE, A.LINE_CODE) IN (" + LINE_CODE + ") ";
                    //     sqlString += string.Format(" AND (A.FCT_CODE, A.LINE_CODE) IN ({0})  ", lineCode);
                    //                  string.Format(" AND ") (A.FCT_CODE, A.LINE_CODE)  IN ({0})" ,line_code);
                    //?<= 前置占位不匹配 " + LINE_CODE + "  ?=后置占位不匹配，不匹配的意思是不替换
                    //                        sqlString += " AND (A.FCT_CODE, A.LINE_CODE)  IN ({0})" ,line_code);
                    //                      sqlString += string.Format(" AND ") (A.FCT_CODE, A.LINE_CODE)  IN ({0})" ,line_code);
                    //                        sqlString += string.Format(" AND  (A.FCT_CODE, A.LINE_CODE)  IN ({0})" ,line_code);
                    var replacePattern = @"IN\s*?\(\s*?""\s*?\+\s*?" + parName + @"\s*?\+\s*?""\s*?\)\s*?""\s*?\;";
                    linedata = Regex.Replace(linedata, replacePattern, @" IN ({0})"" ," + oraParName + @");");
                    linedata = Regex.Replace(linedata, @"""\s*?AND", @"string.Format("" AND ");
                }
            }
            return linedata;
        }
        public static string MatchTwoFormatAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            var IsRepalce = linedata.Contains("Replace");
            // sb.AppendFormat(@"   A.BASE_YMD BETWEEN '{0}' AND '{1}'  ", instance.FILTER_START.Replace("-", ""), instance.FILTER_END.Replace("-", ""));
            //sb.AppendFormat(@" AND SUMM.WORK_YMD BETWEEN TO_CHAR(TO_DATE('{0}','YYYYMMDD') -7,'YYYYMMDD') AND '{1}' ", instance.FILTER_START.Replace("-", ""), instance.FILTER_END.Replace("-", ""));
            // where  PLAN_YMD BETWEEN  '{0}' AND '{1}'   AND  LINE_CODE IN(SELECT LINE_CODE FROM TBM_MD_LINE WHERE 1=1 ",Start_Time,End_Time);
            //AND[\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\s\S]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?,\s*?\S+?\s*?\,\s*?\S+\s*?\)\s*?\;
            var regstr = @"[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\s\S]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?,\s*?(\S+?)\s*?\,\s*?(\S+?)\s*?\)\s*?\;";
            if (IsRepalce)
            {
                regstr = @"[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\s\S]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\)\s*?\;";
            }
            Regex reg = new Regex(regstr);
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 2)
                {
                    var replactStr = IsRepalce ? @"(?<=[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\s\S]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?),\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?\,\s*?([\S\s]+?\([\S\s]+?\,[\S\s]+?\))\s*?(?=\)\s*?\;)"
                        : @"(?<=[AND|where|BETWEEN][\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\s\S]*?\'\s*?\{\s*?1\s*?\}\s*?\'[\s\S]*?),\s*?(\S+)\s*?\,\s*?(\S+)\s*?(?=\)\s*?\;)";
                    linedata = Regex.Replace(linedata, replactStr, "");
                    {
                        var parName1 = match.Groups[1].Value;
                        var pars = parName1.Split('.');
                        var oraParName1 = IsRepalce ? pars[pars.Length-2].ToUpper() : pars.Last().ToUpper();
                        var parString = $@"ListParams.Add(new OracleParameter(""{oraParName1}"",{parName1} ));";
                        AddParStringToMethodList(parString, methodList);
                        // '{0}' 替换
                        linedata = Regex.Replace(linedata, @"\'\s*?\{\s*?0\s*?\}\s*?\'", $":{oraParName1}");
                    }

                    {
                        var parName2 = match.Groups[2].Value;
                        var pars = parName2.Split('.');
                        var oraParName2 = IsRepalce ? pars[pars.Length - 2].ToUpper() : pars.Last().ToUpper();
                        var parString2 = $@"ListParams.Add(new OracleParameter(""{oraParName2}"",{parName2} ));";
                        AddParStringToMethodList(parString2, methodList);
                        //'{1}'
                        linedata = Regex.Replace(linedata, @"\'\s*?\{\s*?1\s*?\}\s*?\'", $":{oraParName2}");
                    }
                   

                }
            }
            return linedata;
        }
        public static string MatchInOneLineAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            //  AND  BASE_YY = (SELECT MAX(BASE_YY) FROM TBC_MD_MM WHERE BASE_YY < SUBSTR('{0}',1,4) AND DEL_YN = 'N' AND USE_YN = 'Y') ", starttime);
            //   sqlString += string.Format(" AND A.SHIFT_CODE = '{0}'", instance.SHIFT);
         
            //AND[\S\s]*?\=[\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\S\s]*?\"\s*?\,\s*?\S+\s*?\)
            var regstr = @"[AND|and][\S\s]*?[\=|LIKE][\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'[\S\s]*?""\s*?\,\s*?(\S+)\s*?\)";
            //var regstr=@"AND\s*?[\S\s]+?\s*?\=\s*?\'\s*?\{\s*?0\s*?\}\s*?\'[\S\s]*?""\s*?,\s*?(\S+)\s*?\)"
            Regex reg = new Regex(regstr);
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 1)
                {

                    var parName = match.Groups[1].Value;
                    var oraParName = parName.Split('.').Last().ToUpper();
                    var parString = $@"ListParams.Add(new OracleParameter(""{oraParName}"",{parName} ));";
                    AddParStringToMethodList(parString, methodList);
                    linedata = Regex.Replace(linedata, @"(?<=[AND|and][\S\s]*?[\=|LIKE]\s*?\'\s*?\{\s*?0\s*?\}\s*?\'[\S\s]*?""\s*?),\s*?(\S+)\s*?(?=\))", "");
                    // '{0}' 替换
                    linedata = Regex.Replace(linedata, @"\'\s*?\{\s*?0\s*?\}\s*?\'", $":{oraParName}");

                }
            }
            return linedata;
        }
        public static string MatchInAddToList(string linedata, List<string> methodList)
        {
            if (Regex.IsMatch(linedata, MuitInOneLinePattern, RegexOptions.IgnoreCase))
            {
                return linedata;
            }
            var sb = new StringBuilder();
            // sql += string.Format(@" AND     T1.DEFT_SYMP_CODE in ({0}) ", instance.FILTER_DEFECT_SYMPT_CODE);
            Regex reg = new Regex(@"AND[\s\S]*?IN\s*?\(\s*?\{\s*?0\s*?\}\s*?\)[\s\S]*?""\s*?,\s*?(\S+)\s*?\)\s*?;",RegexOptions.IgnoreCase);
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 1)
                {

                    var parName = match.Groups[1].Value;
                    var oraParName = parName.Split('.').Last().ToLower();
                    
                    var parString = $@"string {oraParName} =  DbHelperOra.GetParameterKeysAndValues(""{oraParName.ToUpper()}"", {parName}, ListParams);";
                    AddParStringToMethodList(parString, methodList);
                    //?<= 前置占位不匹配 , MFG_PART_CODE  ?=后置占位不匹配，不匹配的意思是不替换
                    linedata = Regex.Replace(linedata, @"(?<=AND[\s\S]*?IN\s*?\(\s*?\{\s*?0\s*?\}\s*?\)[\s\S]*?""\s*?,)\s*?\S+\s*?(?=\)\s*?;)", $"{oraParName}",RegexOptions.IgnoreCase);
                }
            }
            return linedata;
        }
        const string MuitInOneLinePattern = @"AND\s*?\(\s*?\S*?FCT_CODE[\s\S]*?IN\s*?\(\s*?\{\s*?0\s*?\}\s*?\)[\s\S]*?""\s*?,\s*?(\S+)\s*?\)";
        public static string MatchMuitInOneLineAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            // sql += string.Format(@" AND     T1.DEFT_SYMP_CODE in ({0}) ", instance.FILTER_DEFECT_SYMPT_CODE);
            //   //  AND     (A.FCT_CODE, T6.MFG_PART_CODE) IN ( {0} )  ) ", MFG_PART_CODE);
            // sqlString += string.Format(" AND (A.FCT_CODE, A.MFG_PART_CODE) IN ({0})  ", MFG_PART_CODE);
            Regex reg = new Regex(MuitInOneLinePattern);
            var matches = reg.Matches(linedata);
            foreach (Match match in matches)
            {
                if (match.Groups.Count > 1)
                {

                    var parName = match.Groups[1].Value;
                    var oraParName = parName.Split('.').Last().ToLower();
                    //var parString = $@"string {oraParName} =  DbHelperOra.GetParameterKeysAndValues(""FCT_CODE,{oraParName.ToUpper()}"", {parName}, ListParams);";
                    var parString = $@"string {oraParName} =  DbHelperOra.GetParameterKeysAndValues(""FCT_CODE,{oraParName.ToUpper()}"", {parName}, ListParams);";
                    AddParStringToMethodList(parString, methodList);
                    //?<= 前置占位不匹配 , MFG_PART_CODE  ?=后置占位不匹配，不匹配的意思是不替换
                    linedata = Regex.Replace(linedata, @"(?<=AND\s*?\(\s*?\S*?FCT_CODE[\s\S]*?IN\s*?\(\s*?\{\s*?0\s*?\}\s*?\)[\s\S]*?""\s*?,)\s*?\S+\s*?(?=\))", $"{oraParName}");
                }
            }
            return linedata;
        }

        public static string MatchSUBSTRAddToList(string linedata, List<string> methodList)
        {
            var sb = new StringBuilder();
            //AND T2.BASE_MM =  TO_NUMBER ( SUBSTR ('{0}', 6, 2)) ", instance.click_date);

            Regex reg = new Regex(@"SUBSTR[\S\s]*?\'\s*?\{\s*?0\s*?\}\s*?\'");
            if (reg.IsMatch(linedata))
            {
                linedata = Regex.Replace(linedata, @"\'\s*?\{\s*?0\s*?\}\s*?\'", ":CLICK_DATE");
                if (linedata.Contains("instance.click_date"))
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""CLICK_DATE"",instance.click_date ));";
                    AddParStringToMethodList(parString, methodList);
                    linedata = Regex.Replace(linedata, @"""\s*?,\s*?instance.click_date", @"""");
                }
            }
            return linedata;

        }
        //AND  A.WORK_YMD BETWEEN '{0}' AND '{1}' 
        //AND  A.WORK_YMD BETWEEN '{1}' AND '{2}' 
        public static string MatchWORK_YMDAddToList(string linedata, List<string> methodList)
        {
            if (linedata.Contains("AND  A.WORK_YMD BETWEEN '{0}' AND '{1}'"))
            {
                linedata = linedata.Replace("'{0}'", ":START_WORK_YMD").Replace("'{1}'", ":END_WORK_YMD");
            }
            else if(linedata.Contains("AND  A.WORK_YMD BETWEEN '{1}' AND '{2}'"))
            {
                linedata = linedata.Replace("'{1}'", ":START_WORK_YMD").Replace("'{2}'", ":END_WORK_YMD");
            }
            else if (linedata.Contains(@""", model.START_WORK_YMD, model.END_WORK_YMD); "))
            {
                linedata.Replace(", model.START_WORK_YMD, model.END_WORK_YMD", "");

                {
                    var parString = $@"ListParams.Add(new OracleParameter(""START_WORK_YMD"",model.START_WORK_YMD ));";
                    AddParStringToMethodList(parString, methodList);
                }
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""END_WORK_YMD"",model.END_WORK_YMD ));";
                    AddParStringToMethodList(parString, methodList);
                }
            }
            else if (linedata.Contains(@""", model.IDC_DTL_CODE, model.START_WORK_YMD, model.END_WORK_YMD); "))
            {
                linedata.Replace(", model.IDC_DTL_CODE, model.START_WORK_YMD, model.END_WORK_YMD","");
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""IDC_DTL_CODE"",model.IDC_DTL_CODE ));";
                    AddParStringToMethodList(parString, methodList);
                }
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""START_WORK_YMD"",model.START_WORK_YMD ));";
                    AddParStringToMethodList(parString, methodList);
                }
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""END_WORK_YMD"",model.END_WORK_YMD ));";
                    AddParStringToMethodList(parString, methodList);
                }
            }
            return linedata;

        }
        //sql.AppendLine(CommonDao.GetOrgSql_fctCode_lineCode(model));
        public static string MatchGetOrgSql_fctCode_lineCodeAddToList(string linedata, List<string> methodList)
        {
            if (linedata.Contains("sql.AppendLine(CommonDao.GetOrgSql_fctCode_lineCode(model))"))
            {
                linedata = linedata.Replace("GetOrgSql_fctCode_lineCode(model)", "GetOrgSql_fctCode_lineCode_New(model,ListParams)");
            }
            return linedata;
        }
        //WHERE A.IDC_DTL_CODE = '{0}'
        public static string MatchIDC_DTL_CODEAddToList(string linedata, List<string> methodList)
        {
            if (linedata.Contains("WHERE A.IDC_DTL_CODE = '{0}'")
                ||linedata.Contains("AND A.IDC_DTL_CODE = '{0}' ")
                ||linedata.Contains("AND    B.IDC_DTL_CODE = '{0}' "))
            {
                linedata = linedata.Replace("'{0}'", ":IDC_DTL_CODE");
            }
            else if (linedata.Contains(@""", IDC_DTL_CODE); "))
            {
                linedata.Replace(", IDC_DTL_CODE", "");
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""IDC_DTL_CODE"",IDC_DTL_CODE ));";
                    AddParStringToMethodList(parString, methodList);
                }
            }
            else if (linedata.Contains(@""", model.IDC_DTL_CODE);"))
            {
                linedata.Replace(", model.IDC_DTL_CODE", "");
                {
                    var parString = $@"ListParams.Add(new OracleParameter(""IDC_DTL_CODE"",model.IDC_DTL_CODE ));";
                    AddParStringToMethodList(parString, methodList);
                }
            }
            return linedata;
        }
        public static void AddParStringToMethodList(string parString, List<string> methodList)
        {
            IsChanged = true;
            if (IsEndLine)
            {
                addParmStr.Add(parString);
                NeedAddParmStr = true;
            }
            else
            {
                methodList.Add($"{lineRowNum}  {parString}");
            }
           
            
        }
    }
}
